package cn.agiledata.bank.transaction.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.agiledata.bank.hibernateBean.Transaction;
import cn.agiledata.bank.transaction.form.PostRemitInpourForm;

/**
 * 邮局汇款充值
 * 
 * @author maxianbo
 * 
 */
public final class PostRemitInpourAction extends OfflineInpourAction {
    public ActionForward modify(ActionMapping mapping, ActionForm actionForm,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        ActionForward forward = prepare(mapping, actionForm, request, response);
        PostRemitInpourForm form = (PostRemitInpourForm) actionForm;
        Transaction trans = getTransactionTemplate().getTransactionByTranId(
                form.getTransId());
        loadForm(form, trans);
        return forward;
    }

    private void loadForm(PostRemitInpourForm form, Transaction trans) {
        form.setAmount(trans.getAmount().toString());
        form.setNextStep(2);
        form.setRemark(trans.getRemark());
        form.setTransId(trans.getTransId());
        if (trans.getBankCitySeq() != null)
            form.setRemitCityId(trans.getBankCitySeq().toString());
        if (trans.getBankProvSeq() != null)
            form.setRemitProvinceId(trans.getBankProvSeq().toString());
        form.setSubAccountId(trans.getCredit().getAccountId());
    }
}
